package com.yun.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.yun.entity.MClass;
import com.yun.entity.MExam;
import com.yun.entity.MSubject;
import com.yun.service.MarkingProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * (MSubject)表控制层
 *
 * @author makejava
 * @since 2021-10-27 14:04:35
 */
@CrossOrigin("*")
@RestController
@RequestMapping("MarkingProcessController")
public class MarkingProcessController {


    /**
     * 服务对象
     */
    @Autowired
    private MarkingProcessService markingProcessService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public MSubject selectOne(Integer id) {
        return this.markingProcessService.queryById(id);
    }

    /**
     * 教师讲卷-成绩与答卷
     * 通过考试ID查询考试科目
     *
     * @return
     */
    @RequestMapping("findSubNm")
    public List<MSubject> findSubNm(Integer examId) {
        List<MSubject> mSubjectListinfo = new ArrayList<>();
        mSubjectListinfo = markingProcessService.querySubNm(examId);
        return mSubjectListinfo;
    }

    /**
     * 教师讲卷-成绩与答卷
     * 查询考试班级
     *
     * @param examId
     * @return
     */
    @RequestMapping("findClaNm")
    public List<MClass> findClaNm(Integer examId) {
        List<MClass> mClassList = new ArrayList<>();
        mClassList = markingProcessService.queryClaNm(examId);
        return mClassList;
    }


    /**
     * 教师讲卷-成绩与答卷
     * 查询考试ID和考试名称
     *
     * @param
     * @return
     */

    @HystrixCommand
    @RequestMapping("findExamIdAndExamNm")
    public List<MExam> findExamIdAndExamNm() {
        List<MExam> mExamList = new ArrayList<>();
        mExamList = markingProcessService.queryExamIdAndExamNm();
        return mExamList;
    }


    @GetMapping("/test")
    public String test() {
        return "success";
    }

    public String testgitSucess() {
        return "";
    }

}